<template>
  <div class="dog">
    <img 
   src="https://scpic.chinaz.net/files/pic/pic9/202003/zzpic23514.jpg" alt=""
   >
   <p :style="{'background-color': colors}" @click="btn">这是一个孤独的狗</p>
  </div>
</template>

<script> 
export default {
 data() {
  return {
   colors:''
  }
 },
 methods: {
  btn() {
    this.colors = `rgb(${Math.floor(Math.random()*256)},${Math.floor(Math.random()*256)},${Math.floor(Math.random()*256)})`
  }
 }
}
</script>

<style>
.dog {
 float: left;
 width: 200px;
 height: 200px;
}
img {
 width: 70%;
 height: 70%;
}
</style>